package org.dreamwork.seagragon.filesystem;

import javax.servlet.*;
import java.io.IOException;

/**
 * Created by IntelliJ IDEA.
 * User: seth
 * Date: 2010-4-24
 * Time: 18:32:00
 */
public class FSRequestDispatcher implements RequestDispatcher {
    private FSServletContext context;
    private String url;

    public FSRequestDispatcher (FSServletContext context, String url) {
        this.context = context;
        this.url = url;
    }

    public void forward (ServletRequest request, ServletResponse response) throws ServletException, IOException {
        Servlet servlet = context.findServlet (url);
        if (servlet != null) servlet.service (request, response);
        else throw new ServletException ("404");
    }

    public void include (ServletRequest request, ServletResponse response) throws ServletException, IOException {
        forward (request, response);
    }
}